Update suspend/resume for new console code.
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Sat, 3 Sep 2005 18:48:39 +0000 (18:48 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Sat, 3 Sep 2005 18:48:39 +0000 (18:48 +0000)
- translate console mfn to pfn
- unbind/bind console evtchn
- recover console mfn on restore
- trigger xenconsoled refresh after mfn is put in store
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
linux-2.6-xen-sparse/arch/xen/kernel/reboot.c
linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c
tools/libxc/xc_linux_restore.c
tools/libxc/xc_linux_save.c
tools/libxc/xenguest.h
tools/python/xen/xend/XendCheckpoint.py
tools/python/xen/xend/XendDomainInfo.py
tools/xcutils/xc_restore.c

index 82448a527efffe6ce346a299530438fa362cac10..af06ae5a5839621aee49f2aef0609c1126c29e9b 100644 (file)
@@ -96,6 +96,9 @@ static int __do_suspend(void *ignore)
     int restore_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt);
 #endif
 
+    extern void xencons_suspend(void);
+    extern void xencons_resume(void);
+
     int err = 0;
 
     BUG_ON(smp_processor_id() != 0);
@@ -169,6 +172,8 @@ static int __do_suspend(void *ignore)
     smp_suspend();
 #endif
 
+    xencons_suspend();
+
     xenbus_suspend();
 
     ctrl_if_suspend();
@@ -214,6 +219,8 @@ static int __do_suspend(void *ignore)
 
     xenbus_resume();
 
+    xencons_resume();
+
 #ifdef CONFIG_SMP
     smp_resume();
 #endif
index 6987d1a258f207fda674d4db39f09f3fe7447bea..6083c6a326ad4ba98496762e4d44abf5cd82ec32 100644 (file)
@@ -101,19 +101,17 @@ int xencons_ring_init(void)
        if (!xen_start_info.console_evtchn)
                return 0;
 
-       err = bind_evtchn_to_irqhandler(
-               xen_start_info.console_evtchn, handle_input,
-               0, "xencons", inring());
+       err = bind_evtchn_to_irqhandler(xen_start_info.console_evtchn,
+                                       handle_input, 0, "xencons", inring());
        if (err) {
                xprintk("XEN console request irq failed %i\n", err);
-               unbind_evtchn_from_irq(xen_start_info.console_evtchn);
                return err;
        }
 
        return 0;
 }
 
-void xencons_suspend_comms(void)
+void xencons_suspend(void)
 {
 
        if (!xen_start_info.console_evtchn)
@@ -122,3 +120,8 @@ void xencons_suspend_comms(void)
        unbind_evtchn_from_irqhandler(xen_start_info.console_evtchn, inring());
 }
 
+void xencons_resume(void)
+{
+
+       (void)xencons_ring_init();
+}
index 9e55bb1266cb5cbb41a963aaf91b1b49c39479ba..9e3acb8d81ae4082f203a9756660f61bd92629c6 100644 (file)
@@ -53,7 +53,8 @@ read_exact(int fd, void *buf, size_t count)
 }
 
 int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns,
-                    unsigned int store_evtchn, unsigned long *store_mfn)
+                    unsigned int store_evtchn, unsigned long *store_mfn,
+                    unsigned int console_evtchn, unsigned long *console_mfn)
 {
     dom0_op_t op;
     int rc = 1, i, n, k;
@@ -486,6 +487,9 @@ int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns,
     *store_mfn = p_srec->resume_info.store_mfn   =
        pfn_to_mfn_table[p_srec->resume_info.store_mfn];
     p_srec->resume_info.store_evtchn = store_evtchn;
+    *console_mfn = p_srec->resume_info.console_mfn   =
+       pfn_to_mfn_table[p_srec->resume_info.console_mfn];
+    p_srec->resume_info.console_evtchn = console_evtchn;
     munmap(p_srec, PAGE_SIZE);
 
     /* Uncanonicalise each GDT frame number. */
index d0797b15ae294086dfd31f168d5ea6a5e5701214..de4480dee4e93cbea27347a6902726723cde3bea 100644 (file)
@@ -686,6 +686,12 @@ int xc_linux_save(int xc_handle, int io_fd, u32 dom, u32 max_iters,
        goto out;
     }
 
+    /* Canonicalize console mfn. */
+    if ( !translate_mfn_to_pfn(&p_srec->resume_info.console_mfn) ) {
+       ERR("Console frame is not in range of pseudophys map");
+       goto out;
+    }
+
     print_stats( xc_handle, dom, 0, &stats, 0 );
 
     /* Now write out each data page, canonicalising page tables as we go... */
index 10467e84762212a0431ee3ddea619f0b9331858d..b5797357b3d7b4bfc65a6746aead7fb94fe1c2f0 100644 (file)
@@ -37,7 +37,8 @@ int xc_linux_save(int xc_handle, int fd, uint32_t dom, uint32_t max_iters,
  */
 int xc_linux_restore(int xc_handle, int io_fd, uint32_t dom, 
                      unsigned long nr_pfns, unsigned int store_evtchn, 
-                     unsigned long *store_mfn);
+                     unsigned long *store_mfn, unsigned int console_evtchn,
+                    unsigned long *console_mfn);
 
 int xc_linux_build(int xc_handle,
                    uint32_t domid,
index 0157c25cd5c71749afbdf437baf94617bcc38688..81d34b8f459396d51126b84599fa8b35905f3722 100644 (file)
@@ -127,12 +127,18 @@ def restore(xd, fd):
             "not a valid guest state file: pfn count out of range")
 
     if dominfo.store_channel:
-        evtchn = dominfo.store_channel.port2
+        store_evtchn = dominfo.store_channel.port2
     else:
-        evtchn = 0
+        store_evtchn = 0
+
+    if dominfo.console_channel:
+        console_evtchn = dominfo.console_channel.port2
+    else:
+        console_evtchn = 0
 
     cmd = [PATH_XC_RESTORE, str(xc.handle()), str(fd),
-           str(dominfo.id), str(nr_pfns), str(evtchn)]
+           str(dominfo.id), str(nr_pfns),
+           str(store_evtchn), str(console_evtchn)]
     log.info("[xc_restore] " + join(cmd))
     child = xPopen3(cmd, True, -1, [fd, xc.handle()])
     child.tochild.close()
@@ -153,6 +159,7 @@ def restore(xd, fd):
             if fd == child.fromchild.fileno():
                 l = child.fromchild.readline()
                 while l:
+                    log.info(l.rstrip())
                     m = re.match(r"^(store-mfn) (\d+)\n$", l)
                     if m:
                         if dominfo.store_channel:
@@ -162,7 +169,11 @@ def restore(xd, fd):
                                                            dominfo.store_mfn,
                                                            dominfo.store_channel)
                             dominfo.exportToDB(save=True, sync=True)
-                    log.info(l.rstrip())
+                    m = re.match(r"^(console-mfn) (\d+)\n$", l)
+                    if m:
+                        dominfo.console_mfn = int(m.group(2))
+                        dominfo.exportToDB(save=True, sync=True)
+                        dominfo.publish_console()
                     try:
                         l = child.fromchild.readline()
                     except:
index cd7801a5b4940da04fa6e73841771af1ae30acc6..cd73b07a970b550967372a8b9e881865a502fe4e 100644 (file)
@@ -661,6 +661,7 @@ class XendDomainInfo:
             self.configure_restart()
             self.construct_image()
             self.configure()
+            self.publish_console()
             self.exportToDB(save=True)
         except Exception, ex:
             # Catch errors, cleanup and re-raise.
@@ -1084,7 +1085,6 @@ class XendDomainInfo:
         self.configure_fields()
         self.create_devices()
         self.create_blkif()
-        self.publish_console()
 
     def create_blkif(self):
         """Create the block device interface (blkif) for the vm.
index c5d3c84c4c273f3de7da6bb11c3671dacaead8ea..c94dbd3bbeb43647341c6145f1846f737a31c1b0 100644 (file)
 int
 main(int argc, char **argv)
 {
-    unsigned int xc_fd, io_fd, domid, nr_pfns, evtchn;
+    unsigned int xc_fd, io_fd, domid, nr_pfns, store_evtchn, console_evtchn;
     int ret;
-    unsigned long mfn;
+    unsigned long store_mfn, console_mfn;
 
-    if (argc != 6)
-       errx(1, "usage: %s xcfd iofd domid nr_pfns evtchn", argv[0]);
+    if (argc != 7)
+       errx(1,
+            "usage: %s xcfd iofd domid nr_pfns store_evtchn console_evtchn",
+            argv[0]);
 
     xc_fd = atoi(argv[1]);
     io_fd = atoi(argv[2]);
     domid = atoi(argv[3]);
     nr_pfns = atoi(argv[4]);
-    evtchn = atoi(argv[5]);
+    store_evtchn = atoi(argv[5]);
+    console_evtchn = atoi(argv[6]);
 
-    ret = xc_linux_restore(xc_fd, io_fd, domid, nr_pfns, evtchn, &mfn);
+    ret = xc_linux_restore(xc_fd, io_fd, domid, nr_pfns, store_evtchn,
+                          &store_mfn, console_evtchn, &console_mfn);
     if (ret == 0) {
-       printf("store-mfn %li\n", mfn);
+       printf("store-mfn %li\n", store_mfn);
+       printf("console-mfn %li\n", console_mfn);
        fflush(stdout);
     }
     return ret;